package cz.khfotbal.dao.impl;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cz.khfotbal.dao.PropertyDao;
import cz.khfotbal.domain.Propertykh;

@Repository
@Transactional
public class PropertyDaoImpl implements PropertyDao{

	@Autowired
	private SessionFactory sessionFactory;

	private Session session;
	
	public void updateProperty(Propertykh property) {
		session = sessionFactory.getCurrentSession();
		session.merge(property);
	}

	public Propertykh findPropertyByName(String name) {
		session = sessionFactory.getCurrentSession();
		Propertykh property = (Propertykh) session.createQuery("from Propertykh where name = '"+name+"'").uniqueResult();
		return property;
	}

}
